//package com.liwen.service.mq;
//
//import com.alibaba.rocketmq.client.producer.SendResult;
//import com.alibaba.rocketmq.client.producer.SendStatus;
//import com.weidai.rocketmq.client.MQException;
//import com.weidai.rocketmq.client.SimpleProducer;
//import com.weidai.rocketmq.client.StringMessage;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//
///**
// * @author: li.rui
// * @time: 2018-03-19 16:08
// * @description:
// */
//@Service
//public class MQService {
//
//    private static Logger log = LoggerFactory.getLogger(MQService.class);
//
//    @Resource
//    private SimpleProducer rocket;
//
//
//    /**
//     * 发送消息至rocketMQ
//     *
//     * @param topic rocket topic
//     * @param json  消息实体
//     */
//    public boolean rocket(String topic, String json) {
//        if (null == json)
//            return false;
//        try {
//            SendResult result = rocket.sendMessage(topic, new StringMessage(json));
//            if (null == result || !SendStatus.SEND_OK.equals(result.getSendStatus())) {
//                return false;
//            }
//            return true;
//        } catch (MQException e) {
//            log.error("rocket-err=topic:{},json:{}", topic, json);
//            return false;
//        }
//    }
//}
